<?php

/**
 * inicio actions.
 *
 * @package    isaac
 * @subpackage inicio
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class inicioActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */

    public function executeIndex(sfWebRequest $request)
    {
        $this->nombre = "cacho rios";
        $this->formulario = new LoginForm();

        if ($request->isMethod('post')){
            $this->formulario->bind($request->getParameter("login"));
            if ($this->formulario->isValid())
            {
                $this->executeSignin($this->formulario->getValues());
                //$this->redirect('contacto/gracias?'.http_build_query($this->formulario->getValues()));
            }
        }
    }


    private function executeSignin($login)
    {
        $user = $this->getUser();
        if ($user->isAuthenticated())
        {
            return $this->redirect('@homepage');
        } 
        $user->signin($login['user']);
       // simpre redirecciona en el url definido en app.yml
       $signinUrl = sfConfig::get('app_modulos_urlempresa', $user->getReferer('@homepage'));
       
       return $this->redirect($signinUrl);


    }
}